package com.foreveross.vo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.format.annotation.DateTimeFormat;

import com.foreveross.common.Constants;

@Entity
@Table(name = "hr_optimized", catalog = "hrtenement")
public class HrOptimized implements java.io.Serializable {

	private String id;
	private String title;
	private String image;
	private String content;
	private String contentImgList;
	private SysUser publisherId;
	private SysUser createId;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date createTime;
	private HrHouses houseId;
	private Integer isWeichatSend;
	private String imagePath;
	private String link_url;
	private Object other;
	private Integer isAll;
	private List<OptimizedHouse> optimizedHouses = new ArrayList<OptimizedHouse>();
	
	public HrOptimized() {
	}

	@Id
	@GenericGenerator(name = "idGenerator", strategy = "uuid")
	@GeneratedValue(generator = "idGenerator")
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}
	
	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	
	@Column(name = "content_img_list")
	public String getContentImgList() {
		return contentImgList;
	}

	public void setContentImgList(String contentImgList) {
		this.contentImgList = contentImgList;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "publisher_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public SysUser getPublisherId() {
		return publisherId;
	}

	public void setPublisherId(SysUser publisherId) {
		this.publisherId = publisherId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "create_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public SysUser getCreateId() {
		return createId;
	}

	public void setCreateId(SysUser createId) {
		this.createId = createId;
	}

	@Column(name = "create_time")
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	@Column(name = "is_all")
	public Integer getIsAll() {
		return isAll;
	}

	public void setIsAll(Integer isAll) {
		this.isAll = isAll;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "house_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public HrHouses getHouseId() {
		return houseId;
	}

	public void setHouseId(HrHouses houseId) {
		this.houseId = houseId;
	}

	@Column(name = "is_weichat_send")
	public Integer getIsWeichatSend() {
		return isWeichatSend;
	}

	public void setIsWeichatSend(Integer isWeichatSend) {
		this.isWeichatSend = isWeichatSend;
	}
		
	@Column(name = "link_url")
	public String getLink_url() {
		return link_url;
	}

	public void setLink_url(String link_url) {
		this.link_url = link_url;
	}

	@Transient
	public String getImagePath() {
		return imagePath;
	}

	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}
	
	@Transient
	public Object getOther() {
		return other;
	}

	public void setOther(Object other) {
		this.other = other;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "optimized")
	public List<OptimizedHouse> getOptimizedHouses() {
		return optimizedHouses;
	}

	public void setOptimizedHouses(List<OptimizedHouse> optimizedHouses) {
		this.optimizedHouses = optimizedHouses;
	}
	
}
